//----------------------------------------------------------------------------
// M A R I T I M E  R E S E A R C H  I N S T I T U T E  N E T H E R L A N D S
//----------------------------------------------------------------------------
// Copyright (C) 2011 - MARIN - All rights reserved - http://www.marin.nl
//----------------------------------------------------------------------------
// Program    : mermaid
// Module     : vbm
// File       : CudaIpDiagSolver.cpp
//----------------------------------------------------------------------------

#include "CudaIpDiagSolver.h"
#include "assertplus.h"

#define COLUMNS  (unsigned)(Nx1 + 3)
#define ROWS     (unsigned)(Nx2 + 3)

/// constructor
CudaIpDiagSolver::CudaIpDiagSolver(Array2D<REAL> *pmatC, ///< central array
                       Array2D<REAL> *pmatS, ///< south array
                       Array2D<REAL> *pmatW, ///< west array
                       int Nx1, ///< width
                       int Nx2, ///< height
                       REAL tolerance) ///< solver tolerance
: base(Nx1, Nx2, tolerance)
{
    ASSERT(pmatC->dim1() == COLUMNS && pmatC->dim2() == ROWS, "c array size mismatch");
    ASSERT(pmatS->dim1() == COLUMNS && pmatS->dim2() == ROWS, "s array size mismatch");
    ASSERT(pmatW->dim1() == COLUMNS && pmatW->dim2() == ROWS, "w array size mismatch");

    setup(pmatC, pmatS, pmatW, Nx1, Nx2, tolerance);
}


/// destructor
CudaIpDiagSolver::~CudaIpDiagSolver()
{
    clean();
}


/// solves system with CG on GPU
void CudaIpDiagSolver::solve(Array2D<REAL> *pB, ///< pointer to right hand side bpsi
                             Array2D<REAL> *pX) ///< pointer to psi
{
    start(pB, pX);
}

